package com.seawater.http;

import feign.Feign;
import feign.Request;
import feign.okhttp.OkHttpClient;

public class ApiClient {

    public interface Api{

    }

    private final String basePath;
    private final Feign.Builder feignBuilder;

    public ApiClient(String host, String appId, String appSecret) {
        basePath = host + "/";
        feignBuilder = Feign.builder()
                .client(new OkHttpClient())
                .options(new Request.Options(2000, 5000))
                .requestInterceptor(new AuthorizationRequestInterceptor(appId, appSecret));
    }

    public <T extends Api> T buildClient(Class<T> clientClass) {
        return feignBuilder.target(clientClass, basePath);
    }
}
